import logging
import unittest,time
from selenium import webdriver
from month_99.Page.Page1 import Page1
from month_99.Page.Page2 import Page2
from month_99.Page.Page3 import Page3
from month_99.Tools.Tools import Tools

class TestCase(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.driver.implicitly_wait(10)
        Tools().log()

    def tearDown(self):
        time.sleep(3)
        self.driver.quit()

    def test_01(self):
        logging.info('start case')
        po = Page1(self.driver)
        po.A3mall_01()
        logging.info('case end')

    def test_02(self):
        try:
            logging.info('start case')
            po = Page2(self.driver)
            po.A3mall_01()
            po.shouye()
            po.search()
            time.sleep(3)
            po.searchbtn()
            time.sleep(1)
            po.img()
            po.add()
            logging.info('case end')
        except Exception as e:
            t = time.strftime('%Y%m%d%H%M%S', time.localtime())
            self.driver.save_screenshot(t + '.png')
            print(e)

    def test_03(self):
        try:
            logging.info('start case')
            po = Page3(self.driver)
            po.A3mall_01()
            po.tuango()
            po.goods()
            time.sleep(3)
            po.buy()
            time.sleep(1)
            po.address()
            po.nexta()
            logging.info('case end')
        except Exception as e:
            t = time.strftime('%Y%m%d%H%M%S', time.localtime())
            self.driver.save_screenshot(t + '.png')
            print(e)